#define IDT_SIZE	128	
/**
*进程数目
**/
#define MAX_NUM	3
struct	stackframe{
	u32	ds;
	u32	es;
	u32	fs;
	u32	gs;	
	u32	edi;
	u32	esi;
	u32	ebp;
	u32	addr;
	u32	ebx;
	u32	edx;
	u32	ecx;
	u32	eax;
	u32	eip;
	u32	cs;
	u32	eflags;
	u32	esp;
	u32	ss;
};
struct tss{
	u32	backline;
	u32 	esp0;
	u32	ss0;
	u32	esp1;
	u32	ss1;
	u32	esp2;
	u32	ss2;
	u32	cr3;
	u32	eip;
	u32	eflags;
	u32	eax;
	u32	ecx;
	u32	edx;
	u32	ebx;
	u32	esp;
	u32	ebp;
	u32	esi;
	u32	edi;
	u32	es;
	u32	cs;
	u32	ss;
	u32	ds;
	u32	fs;
	u32	gs;
	u32	ldt;
	u16	trap;
	u16	iobase;
};
struct descriptor{
	u16	limit_low;
	u16	base_low;
	u8	base_mid;
	u8	attribute;
	u8	limit_high:4;
	u8	attribute1:4;
	u8	base_high;
};
struct process{
	struct 	stackframe	frame;
	u16	ldt_selector;
	struct  descriptor	ldt[3];	//数据段 代码段 堆栈段
	u32	pid;
	u8	state;	//Process State 
	u32	counter; //Process time split
	u32	priority; //
	Message*	mail_box;  //信箱
	struct process* next; //下一进程链接	
	struct process* prev; //上一进程链接	
	u32	signal; 
	//char	name[16];
	char* name;
};
struct gate{
	u16	offset_low;
	u16	selector;
	u8	pcount;
	u8	attr2;
	u16	offset_high;
};

#define	GDT_SIZE	128
extern  int ticks;
extern	struct gate idt[IDT_SIZE];
extern	struct descriptor gdt[GDT_SIZE];
extern	struct tss t_tss;
extern	struct	process p_process[MAX_NUM];
extern	struct process* cur;
#define NULL_PROC	(struct process*)0
#define vir2phys(base,vir) (u32)(((u32)base)+((u32)vir))
#define STACK_SIZE_TOTAL	1024*5
#define	FIRSTLDT	48
#define	TSS	32

#define	DA_LIMIT_4K	0b1000
#define DA_32	0b0100
#define	DA_TSS	0b10001001
#define DA_LDT	0b10000010
#define	DA_CR	0b10011001
#define DA_DRW	0b10010010
#define	SA_LDT	0b100
#define	SA_GDT	0b000
#define SA_RPL0	0b000
#define	SA_RPL1	0b001
#define SA_RPL2	0b010
#define	SA_RPL3	0b011
#define DA_DPL0	0b00000000
#define	DA_DPL1	0b00100000
#define	DA_DPL2	0b01000000
#define DA_DPL3	0b01100000


#define READY	0b00  //就绪态
#define	RUN		0b01  //运行态
#define	BLOCK	0b10  //阻塞态
#define DIE		0b11	//死亡态	
